<?php
    include "../database.php";
    
    $data = array('success' => '0');
    $story_id = $_POST["story_id"];
    $method   = $_GET["method"];
    
    if ($method == "confirm"){
        $query = "UPDATE story SET story_finished= '1' WHERE  story_id = '$story_id'";
        $res = executeQuery($query);
        
        $queryDelete = "DELETE FROM task WHERE story_id = '$story_id'";
        $res = executeQuery($queryDelete);  

        $data = array('success' => '1');
    }
    
    if ($method == "reject"){
        $query = "UPDATE story SET story_sprint= '0' WHERE  story_id = '$story_id'";
        $res = executeQuery($query);
        
        $queryDelete = "DELETE FROM task WHERE story_id = '$story_id'";
        $res = executeQuery($queryDelete);       

        $data = array('success' => '1');
    }

    echo json_encode($data);
?>
